
import allVariableJs from "./allVariable";
cc.Class({
    extends: cc.Component,

    properties: {
      hurtSound:{
        default: null,
        type: cc.AudioClip
      }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {

     
       
    },

    start () {

    },

    hurtClick: function () {
        console.log('受到伤害');
        if(allVariableJs.SourceChange==false){
          this.current = cc.audioEngine.play(this.hurtSound, false, 1);
        }
      },
    
      onEnable: function () {
        this.node.on('touchstart', this.hurtClick, this);
        
      },
    
      onDisable: function () {
        this.node.off('touchstart', this.hurtClick, this);
      },

    init(){

      
      if(allVariableJs.isEnterEndTimes==true){

          console.log("进入倒计时时间不显示伤害界面")

      }else{

        var interval = 1;
        // 重复次数
        var repeat =3
        // 开始延时
        var delay = 0;
       
        this.schedule(function(){

          var opaction = cc.fadeTo(0.25, 100);

          var opaction2 = cc.fadeTo(0.25, 200);
  
          var opaction3 = cc.fadeTo(0.25, 100);
  
          var opaction4 = cc.fadeTo(0.25, 200);
  
          var seq = cc.sequence(opaction,opaction2,opaction3,opaction4);
        
          this.node.runAction(seq);

        }, interval, repeat, delay);

      }

    }

});
